home *** CD-ROM | disk | FTP | other *** search
- import java.applet.Applet;
- import java.awt.Button;
- import java.awt.Checkbox;
- import java.awt.CheckboxGroup;
- import java.awt.Choice;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Dialog;
- import java.awt.Frame;
- import java.awt.GridLayout;
- import java.awt.Insets;
- import java.awt.Label;
- import java.awt.LayoutManager;
- import java.awt.TextArea;
- import java.awt.TextComponent;
- import java.awt.TextField;
- import java.awt.Toolkit;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.WindowEvent;
- import java.awt.event.WindowListener;
- import java.io.BufferedReader;
- import java.io.DataOutputStream;
- import java.io.InputStreamReader;
- import java.net.InetAddress;
- import java.net.MalformedURLException;
- import java.net.Socket;
- import java.net.URL;
- import java.net.URLEncoder;
- import java.util.EventObject;
-
- public class Form extends Applet implements WindowListener, ActionListener {
- public String url;
- // $FF: renamed from: wi int
- private int field_0;
- // $FF: renamed from: he int
- private int field_1;
- private String agreeText;
- private String disagreeText;
- private Dialog dialog;
- private int mode;
- private String text;
- private int vSpace = 15;
-
- public String getAppletInfo() {
- return "Name: Form\r\nAuthor: Taiji Software\r\n";
- }
-
- public void register() {
- try {
- URL u = new URL("http://www.taijisoftware.com");
- ((Applet)this).getAppletContext().showDocument(u, "_blank");
- } catch (Exception e) {
- System.out.println(e);
- this.stop();
- }
- }
-
- public void init() {
- String codeBase = null;
-
- try {
- codeBase = (new URL(((Applet)this).getCodeBase().toString())).getHost();
- System.out.println("Copyright 1999, 2001 Taiji Software(tm)\nYour domain name is : " + codeBase);
- codeBase = codeBase.toUpperCase();
- } catch (Exception var9) {
- }
-
- if (!((Applet)this).getCodeBase().toString().toUpperCase().startsWith("FILE") || ((Applet)this).getParameter("debug") != null) {
- String regCode = ((Applet)this).getParameter("registration_code");
- if (regCode == null) {
- regCode = ((Applet)this).getParameter("reg_domain");
- if (regCode == null) {
- this.register();
- } else {
- if (regCode.length() == codeBase.length() + 4 && !codeBase.startsWith("WWW.")) {
- codeBase = "WWW." + codeBase;
- } else if (regCode.length() == codeBase.length() - 4 && codeBase.startsWith("WWW.")) {
- codeBase = codeBase.substring(4);
- }
-
- char[] chars = new char[codeBase.length()];
- codeBase.getChars(0, codeBase.length(), chars, 0);
- String key = new String("haricot");
- char[] chars2 = new char[key.length()];
- key.getChars(0, key.length(), chars2, 0);
-
- for(int i = 0; i < codeBase.length(); ++i) {
- int j;
- if (i >= key.length()) {
- j = i - key.length() * (i / key.length());
- } else {
- j = i;
- }
-
- chars[i] += chars2[j];
- chars[i] = (char)(chars[i] - chars[i] / 26 * 26 + 97);
- }
-
- String res = new String(chars);
- if (!res.equalsIgnoreCase(regCode)) {
- this.register();
- }
- }
- } else if (!regCode.equals("settevercsedegnamiaj") && !regCode.equals("8078")) {
- this.register();
- }
- }
-
- this.getParameters();
- this.putComponents();
- }
-
- public void stop() {
- if (this.dialog != null && this.dialog.isShowing()) {
- this.dialog.dispose();
- }
-
- }
-
- public void getParameters() {
- this.field_0 = ((Component)this).getSize().width;
- this.field_1 = ((Component)this).getSize().height;
- this.agreeText = ((Applet)this).getParameter("button_send_text");
- if (this.agreeText == null) {
- this.agreeText = "Send";
- }
-
- this.disagreeText = ((Applet)this).getParameter("button_cancel_text");
- if (this.disagreeText == null) {
- this.disagreeText = "Cancel";
- }
-
- ((Component)this).setBackground(this.getColor("background_color"));
- String s = ((Applet)this).getParameter("space");
- if (s != null) {
- this.vSpace = Integer.parseInt(s);
- }
-
- }
-
- public Color getColor(String param) {
- String s = ((Applet)this).getParameter(param);
- if (s != null) {
- if (s.substring(0, 1).equals("#")) {
- s = s.substring(1);
- int i = Integer.parseInt(s, 16);
- return new Color(i);
- } else {
- return null;
- }
- } else {
- return null;
- }
- }
-
- public void putComponents() {
- String s = ((Applet)this).getParameter("frame_width");
- int dialogWidth;
- if (s != null) {
- dialogWidth = Integer.parseInt(s);
- } else {
- dialogWidth = 200;
- }
-
- s = ((Applet)this).getParameter("frame_height");
- int dialogHeight;
- if (s != null) {
- dialogHeight = Integer.parseInt(s);
- } else {
- dialogHeight = 200;
- }
-
- s = ((Applet)this).getParameter("mode");
- if (s != null) {
- this.mode = Integer.parseInt(s);
- }
-
- s = ((Applet)this).getParameter("frame_title");
- if (s == null) {
- s = "Information";
- }
-
- Frame f = new Frame();
- this.dialog = new Dialog(f, s);
- this.dialog.setLayout((LayoutManager)null);
- this.dialog.addWindowListener(this);
- Toolkit toolkit = Toolkit.getDefaultToolkit();
- int width = toolkit.getScreenSize().width;
- int height = toolkit.getScreenSize().height;
- if (((Applet)this).getParameter("frame_background_color") != null) {
- this.dialog.setBackground(this.getColor("frame_background_color"));
- } else {
- this.dialog.setBackground((new Button()).getBackground());
- }
-
- this.dialog.setResizable(true);
- this.dialog.setVisible(true);
- this.dialog.setBounds((width - dialogWidth) / 2, (height - dialogHeight) / 2, dialogWidth, dialogHeight);
- Insets insets = this.dialog.getInsets();
- this.dialog.dispose();
- Button b1 = new Button(this.agreeText);
- Button b2 = new Button(this.disagreeText);
- ((Container)this).add(b1);
- ((Container)this).add(b2);
- int w = ((Component)b1).getPreferredSize().width;
- int w2 = ((Component)b2).getPreferredSize().width;
- if (w2 > w) {
- w = w2;
- }
-
- ((Container)this).remove(b1);
- ((Container)this).remove(b2);
- this.dialog.add(b1);
- this.dialog.add(b2);
- b1.addActionListener(this);
- b2.addActionListener(this);
- int space = (dialogWidth - 2 * w) / 3;
- ((Component)b1).setBounds(space, dialogHeight - 15 - insets.bottom - 20, w, 25);
- ((Component)b2).setBounds(2 * space + w, dialogHeight - 15 - insets.bottom - 20, w, 25);
- ((Component)b1).setName("b1");
- ((Component)b2).setName("b2");
- int vCount = insets.top + 5;
- int cWidth = 0;
- int cHeight = 0;
- int n = 1;
-
- while(true) {
- s = ((Applet)this).getParameter("component" + Integer.toString(n));
- if (s == null) {
- s = ((Applet)this).getParameter("button_show_text");
- if (s == null) {
- s = "Enter !";
- }
-
- if (this.mode == 1) {
- Button showButton = new Button(s);
- showButton.addActionListener(this);
- ((Container)this).setLayout(new GridLayout(1, 1));
- ((Container)this).add(showButton);
- return;
- }
-
- this.dialog.show();
- return;
- }
-
- String[] params = this.getStrings(s);
- if (!params[0].equals("label")) {
- cWidth = Integer.parseInt(params[2]);
- cHeight = Integer.parseInt(params[3]);
- }
-
- if (params[0].equals("label")) {
- cWidth = Integer.parseInt(params[1]);
- cHeight = Integer.parseInt(params[2]);
- Label l = new Label(params[3]);
- ((Component)l).setName("out");
- this.dialog.add(l);
- if (cWidth == 0) {
- cWidth = 15 + 7 * params[3].length();
- }
-
- if (cHeight == 0) {
- cHeight = 15;
- }
-
- ((Component)l).setBounds(10, vCount, cWidth, cHeight);
- vCount += cHeight;
- }
-
- if (params[0].equals("checkbox")) {
- boolean checked = false;
- if (params[5].equals("yes")) {
- checked = true;
- }
-
- Checkbox c = new Checkbox(params[4], checked);
- ((Component)c).setName(params[1]);
- this.dialog.add(c);
- if (cWidth == 0) {
- cWidth = 15 + 8 * params[4].length();
- }
-
- if (cHeight == 0) {
- cHeight = 20;
- }
-
- ((Component)c).setBounds(10, vCount, cWidth, cHeight);
- vCount += cHeight + this.vSpace;
- } else if (params[0].equals("radiogroup")) {
- CheckboxGroup cbg = new CheckboxGroup();
- int NChecked = Integer.parseInt(params[params.length - 1]);
-
- for(int i = 4; i < params.length - 1; ++i) {
- cWidth = Integer.parseInt(params[2]);
- cHeight = Integer.parseInt(params[3]);
- boolean checked = false;
- if (i == NChecked + 3) {
- checked = true;
- }
-
- Checkbox c = new Checkbox(params[i], cbg, checked);
- ((Component)c).setName(params[1]);
- this.dialog.add(c);
- if (cWidth == 0) {
- cWidth = 25 + 8 * params[i].length();
- }
-
- if (cHeight == 0) {
- cHeight = 20;
- } else {
- cHeight /= params.length - 5;
- }
-
- ((Component)c).setBounds(10, vCount, cWidth, cHeight);
- if (i != params.length - 2) {
- vCount += cHeight + 4;
- }
- }
-
- vCount += cHeight + this.vSpace;
- } else if (params[0].equals("combobox")) {
- Choice c = new Choice();
- ((Component)c).setName(params[1]);
- int NChecked = Integer.parseInt(params[params.length - 1]);
- int lMax = 0;
-
- for(int i = 4; i < params.length - 1; ++i) {
- c.add(params[i]);
- if (params[i].length() > lMax) {
- lMax = params[i].length();
- }
-
- this.dialog.add(c);
- }
-
- c.select(NChecked - 1);
- if (cWidth == 0) {
- cWidth = 15 + 8 * lMax;
- }
-
- if (cHeight == 0) {
- cHeight = 20;
- }
-
- ((Component)c).setBounds(10, vCount, cWidth, cHeight);
- vCount += cHeight + this.vSpace;
- } else if (params[0].equals("textfield")) {
- TextField tf = new TextField();
- ((Component)tf).setName(params[1]);
- if (cWidth == 0) {
- cWidth = 15 + 7 * params[4].length();
- }
-
- if (cHeight == 0) {
- cHeight = 20;
- }
-
- this.dialog.add(tf);
- ((Component)tf).setBounds(10, vCount, cWidth, cHeight);
- ((TextComponent)tf).setText(params[4]);
- vCount += cHeight + this.vSpace;
- } else if (params[0].equals("textarea")) {
- String text = "";
- int l = 0;
-
- for(int i = 4; i < params.length; ++i) {
- text = text + params[i] + "\n";
- if (params[i].length() > l) {
- l = params[i].length();
- }
- }
-
- TextArea ta = new TextArea(text);
- ((Component)ta).setName(params[1]);
- if (cWidth == 0) {
- cWidth = 30 + 7 * l;
- }
-
- if (cHeight == 0) {
- cHeight = 60;
- }
-
- this.dialog.add(ta);
- ((Component)ta).setBounds(10, vCount, cWidth, cHeight);
- vCount += cHeight + this.vSpace;
- }
-
- ++n;
- }
- }
-
- public void send(String body) {
- String sender = ((Applet)this).getParameter("sender_email");
- if (sender == null) {
- sender = "home@taijisoftware.com";
- }
-
- String recipient = ((Applet)this).getParameter("recipient_email");
- if (recipient == null) {
- recipient = "home@taijisoftware.com";
- }
-
- System.out.println(sender);
- System.out.println(recipient);
- String ip = null;
-
- try {
- ip = InetAddress.getLocalHost().getHostAddress();
- } catch (Exception var11) {
- ip = "could not read ip";
- }
-
- System.out.println(ip);
- String host = null;
-
- try {
- host = InetAddress.getLocalHost().getHostName();
- } catch (Exception var10) {
- host = "could not read host name";
- }
-
- System.out.println(host);
-
- try {
- System.out.println(((Applet)this).getCodeBase().getHost());
- Socket sock = new Socket(((Applet)this).getCodeBase().getHost(), 25);
- System.out.println("socket ok");
- DataOutputStream out = new DataOutputStream(sock.getOutputStream());
- System.out.println("out ok");
- BufferedReader in = new BufferedReader(new InputStreamReader(sock.getInputStream()));
- System.out.println("in ok");
- this.isOk(in);
- out.writeBytes("HELO FormApplet\r\n");
- this.isOk(in);
- out.writeBytes("MAIL FROM:<" + sender + ">\r\n");
- this.isOk(in);
- out.writeBytes("RCPT TO:<" + recipient + ">\r\n");
- this.isOk(in);
- out.writeBytes("DATA\r\n");
- this.isOk(in);
- out.writeBytes(body + "\r\n.\r\nQUIT\r\n");
- this.isOk(in);
- sock.close();
- } catch (Exception e) {
- System.out.println(e);
- }
- }
-
- public void isOk(BufferedReader in) {
- String s = "";
-
- try {
- s = in.readLine();
- System.out.println(s);
- } catch (Exception e) {
- System.out.println("problem: " + ((Throwable)e).toString());
- this.stop();
- }
-
- if (s.startsWith("4") || s.startsWith("5")) {
- System.out.println(s);
- this.stop();
- }
-
- }
-
- public String[] getStrings(String s) {
- int p = 0;
-
- int n;
- for(n = 0; (p = s.indexOf("#", p)) != -1; ++p) {
- ++n;
- }
-
- String[] values = new String[n + 1];
-
- for(int i = 0; i < n; ++i) {
- p = s.indexOf("#");
- values[i] = s.substring(0, p);
- s = s.substring(p + 1);
- }
-
- values[n] = s;
- return values;
- }
-
- public void actionPerformed(ActionEvent event) {
- if (((EventObject)event).getSource() instanceof Button) {
- String s = ((Button)((EventObject)event).getSource()).getLabel();
- if (s.equals(this.agreeText)) {
- this.quitDialog(true);
- } else if (s.equals(this.disagreeText)) {
- this.quitDialog(false);
- } else {
- this.dialog.show();
- }
- }
- }
-
- public void quitDialog(boolean agree) {
- String link;
- if (agree) {
- String body = "";
- String header = ((Applet)this).getParameter("email_header");
- if (header == null) {
- header = "Components names and values: \n----------------------------\n";
- } else {
- header = header + "\n\n";
- }
-
- body = body + header;
-
- for(int i = 0; i < this.dialog.getComponentCount(); ++i) {
- Component comp = this.dialog.getComponents()[i];
- String name = comp.getName();
- if (!name.equals("b1") && !name.equals("b2") && !name.equals("out")) {
- if (comp instanceof TextField) {
- body = body + name + ": " + ((TextField)comp).getText() + "\n\n";
- } else if (comp instanceof Checkbox) {
- CheckboxGroup cbg = ((Checkbox)comp).getCheckboxGroup();
- if (cbg == null) {
- String checked = "no";
- if (((Checkbox)comp).getState()) {
- checked = "yes";
- }
-
- body = body + name + ": " + checked + "\n\n";
- } else {
- Checkbox c = (Checkbox)comp;
- if (c.getState()) {
- body = body + ((Component)c).getName() + ": " + c.getLabel() + "\n\n";
- }
- }
- } else if (comp instanceof Choice) {
- body = body + name + ": " + ((Choice)comp).getSelectedItem() + "\n\n";
- } else if (comp instanceof TextArea) {
- body = body + name + ": \n" + ((TextArea)comp).getText() + "\n\n";
- }
- }
- }
-
- System.out.println(body);
- this.send(body);
- link = ((Applet)this).getParameter("send_link");
- } else {
- link = ((Applet)this).getParameter("cancel_link");
- }
-
- if (link != null) {
- String target = ((Applet)this).getParameter("target");
- if (target == null) {
- target = "_blank";
- }
-
- URL u = this.giveURL(link);
- ((Applet)this).getAppletContext().showDocument(u, target);
- }
-
- this.dialog.dispose();
- }
-
- public void windowClosing(WindowEvent e) {
- this.quitDialog(false);
- }
-
- public void windowClosed(WindowEvent e) {
- }
-
- public void windowOpened(WindowEvent e) {
- }
-
- public void windowIconified(WindowEvent e) {
- }
-
- public void windowDeiconified(WindowEvent e) {
- }
-
- public void windowActivated(WindowEvent e) {
- }
-
- public void windowDeactivated(WindowEvent e) {
- }
-
- public URL giveURL(String url) {
- try {
- if (url.toUpperCase().startsWith("HTTP")) {
- return new URL(url);
- } else if (url.toUpperCase().startsWith("FTP")) {
- int p = url.indexOf(":");
- int p2 = url.indexOf(":", p + 1);
- if (p2 != -1) {
- url = url.substring(0, p + 3) + URLEncoder.encode(url.substring(p + 3, url.length()));
- }
-
- p = url.indexOf("%40");
- if (p != -1) {
- url = url.substring(0, p) + "@" + url.substring(p + 3, url.length());
- }
-
- return new URL(url);
- } else {
- return new URL(((Applet)this).getCodeBase(), url);
- }
- } catch (MalformedURLException e) {
- System.out.println(e);
- return null;
- }
- }
- }
-